using System;
using System.Collections.Generic;
using Castle.ActiveRecord;
using CosyTrade.Data;

namespace CosyTrade.StoreManagement
{
    [AddPropertyChangedNotifyInterface, PropertyChangedNotify]
    [Serializable, ActiveRecord("tbProductCategoryRelation")]
    public class ProductCategory : ProductCategoryBase
    {
        private readonly IList<ProductCategoryBase> childs = new List<ProductCategoryBase>();

        [JoinedKey("ROWGUID")]
        public Guid RelationKey
        {
            get { return PrimaryKey; }
        }

        [HasMany(typeof(ProductCategoryBase), ColumnKey = "Childrens", Table = "tbProductCategoryRelation", Access = PropertyAccess.NosetterCamelcase, Cascade = ManyRelationCascadeEnum.Delete)]
        public IList<ProductCategoryBase> Childs
        {
            get { return childs; }
        }

        public override string ToString()
        {
            return CategoryChinese + "(" + CategorySpanish + ")";
        }
    }
}